|
|
|
|
|
|
|
You can use this equation to determine whether two vectors are perpendicular, point in more or less the same direction, or point in opposite directions. |
|
|
|
|
| | |
|
|
|
|
Cos(q) < 0, so the vectors point in more or less opposite directions. |
|
|
|
| | | |
|
|
|
|
Cos(q) = 0, so the vectors are perpendicular. |
|
|
|
| | | |
|
|
|
|
Cos(q) > 0, so the vectors point in more or less the same direction. |
|
|
|
|
|
|
|
|
|
|
If two vectors are parallel, the angle between them is zero, so: |
|
|
|
 |
|
|
|
|
A B = |A| * |B| * Cos(0)
= |A| * |B| |
|
|
|
|
|
|
|
|
Projection of a Vector Onto a Vector |
|
|
|
|
|
|
|
|
You can use the dot product to find the projection of one vector onto another. Figure 19.3 shows the projection A' of the vector A onto the vector B. The definition of the cosine says: |
|
|
|
 |
|
|
|
|
Cos(q) = |A'|/|A| |
|
|
|
|
|
|
|
|
Solving for |A'| and replacing the cosine with the dot product gives: |
|
|
|
 |
|
|
|
|
|A'| = |A| * ((A · B)/(|A| * |B|))
= (A B)/|B| |
|
|
|
|
|
|
|
|
The projection of A onto B is a vector in the same direction as B but that has the length (A B)/|B|. To find this vector, divide B by its length and then multiply by the desired length |A'|. This gives: |
|
|
|
 |
|
|
|
|
(B/|B|) * ((A B)/|B|) = B * (A B)/|B|2 |
|
|
|
|
|
|
|
|
For example, suppose A = <1, 1> and B = <3, 0> as shown in Figure 19.4. Then: |
|
|
|
|
|
|
|
|
Figure 19.3
Projecting the vector A onto the vector B. |
|
|
|
|
|